package cn.dancepeak.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect //aop
//@Component
@Slf4j
public class Tx {
    @Pointcut("execution(* cn.dancepeak.service.I*Service.*(..))")
    public void pointCut(){}
    //开启
    @Before("pointCut()")
    public void begin(){
        log.info("开启事务");
    }
    //提交
    @AfterReturning("pointCut()")
    public void commit(){
        log.info("提交事务");
    }
    //回滚
    @AfterThrowing("pointCut()")
    public void rollBack(){
        log.info("回滚事务");
    }
    //关闭
    @After(("pointCut()"))
    public void close(){
        log.info("关闭事务");
    }
}
